<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
    </head>
    <body>
    <div>div</div>
    <p>p</p>
    <div>div</div>
    <span>span</span>
    <p>p</p>
    <div>div</div>
    </body>
    <script>
        function select(selector){
        	return document.querySelectorAll(selector);//伪数组
        }
        function each(arr,callback){
        	for(var i=0;i<arr.length;i++){
        		callback(arr[i],i);
        	}
        }

        //
        var nodes=select('div,p');
        each(nodes,function(v){
        	v.style.border=v.nodeName=='DIV'//标签的nodeName是大写的
        	               ?'1px solid red'
        	               :'1px solid blue';
        });
        //jQuery中是可以进行链式编程的
        //例如：$('div,p')css(...)
        
        //function func(){
        //     return {
        //        each:fnction(){}
        //     }
        //}
        
        //func().each();
        
    </script>
</html>